
vec4 GetSourceTexture(const ivec2 iDelta)
{
#if !defined(GLES2Platform) && !defined(AMD)
  vec4 col = vTextureOffset(s_SourceTex, vTexCoord, iDelta);

#ifdef CHECK_NAN 
  if(isnan(col.x))
  {
    col = vec4(0);
  }
#endif
  return col;
#else
  ivec2 size = vTextureSize(s_SourceTex, 0);
  vec2 invSize = vec2(1.0/size.x, 1.0/size.y);

  vec2 coord = vTexCoord + iDelta * invSize;
  return vTexture(s_SourceTex, coord);
#endif
}

void main(void)
{
  vec4 col = GetSourceTexture(ivec2(0,0))*0.25;
  
  col += GetSourceTexture(ivec2(-1,-1))*0.0625;
  col += GetSourceTexture(ivec2( 1,-1))*0.0625;
  col += GetSourceTexture(ivec2( 1, 1))*0.0625;
  col += GetSourceTexture(ivec2(-1, 1))*0.0625;
  
  col += GetSourceTexture(ivec2( 0,-1))*0.125;
  col += GetSourceTexture(ivec2( 0, 1))*0.125;
  col += GetSourceTexture(ivec2( 1, 0))*0.125;
  col += GetSourceTexture(ivec2(-1, 0))*0.125;

  FRAGCOLOR = col;
}
